<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">

    <title>Wish wall</title>
    <link href="../lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../wishwall/css/main.css">
    <!--[if lt IE 9]>
      <script src="../lib/html5shiv/html5shiv.min.js"></script>
      <script src="../lib/respond/respond.min.js"></script>
    <![endif]-->
  </head>
  <body class="heart-zuce-background">
<div id="heart-zuce">
  <div class="container">
    <div class="col-md-4"></div>
    <div class="col-md-4">

      <div class="f-center"><h2>Sign in for WishWall</h2></div>
      <div class="heart-zuce-form">
        <form>
        <div class="form-group">
          <label for="username">User name</label>
          <input type="text" class="form-control" id="username" placeholder="Pick a username"></div>
        <div class="form-group">
          <label for="useremail">Email address</label>
          <input type="email" class="form-control" id="useremail" placeholder="Email"></div>
        <div class="form-group">
          <label for="userpassword">Password</label>
          <input type="password" class="form-control" id="userpassword" placeholder="Password"></div>
        <p class="help-block">Use at least one letter, one numeral, and seven characters.</p>
        <button type="button" class="btn btn-success btn-block" id="zhuce">注册</button>
      </form>
      <div id="cuowukuang" class="alert alert-warning" role="alert">用户名或邮箱被占用</div>
      </div>
    </div>
  </div>
</div>
    <script src="../lib/jquery/jquery.js"></script>

    <script src="../lib/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript">
      $("input").focus(function(){
        $("#cuowukuang").fadeOut();
      });
      $("#zhuce").click(function(){

        $.post("/doregist",{
        "username" : $("#username").val(),
        "useremail" : $("#useremail").val(),
        "userpassword" : $("#userpassword").val()
      },function(result){
        if(result=="1"){
          //注册成功
          window.location = "/heart";
        }else if(result=="-1"||result=="-2"){
          //用户名被占用
          $("#cuowukuang").fadeIn();
        }else if(result == "-3"){
          //服务器错误
        }
      });
      });
    </script>
  </body>
</html>